package org.helian.service.impl;

import org.helian.mapper.TbUserMapper;
import org.helian.pojo.TbUser;
import org.helian.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

/**
 * @Description 用户业务层
 * @Author 墨染
 * @Date 2020/11/7 17:47
 * @Version 1.0
 */
@Service("userServiceImpl")
public class UserServiceImpl implements UserService {

    @Autowired
    private TbUserMapper mapper;

    @Override
    public TbUser findByUsernameAndPassword(String username, String password) throws Exception {
        // 条件构造器
        Example example = new Example(TbUser.class);
        Example.Criteria criteria = example.createCriteria();
        // 塞入用户名和密码
        criteria.andEqualTo("username", username);
        criteria.andEqualTo("password", password);
        // 查
        return mapper.selectOneByExample(example);
    }
}
